<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - SimpleHire</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .login-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .login-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            border: none;
            overflow: hidden;
        }
        
        .login-header {
            background: linear-gradient(135deg, #2563eb, #1d4ed8);
            color: white;
            padding: 2rem;
            text-align: center;
        }
        
        .login-body {
            padding: 2.5rem;
        }
        
        .form-control {
            border-radius: 10px;
            border: 2px solid #e5e7eb;
            padding: 0.75rem 1rem;
            font-size: 1rem;
            transition: all 0.3s ease;
        }
        
        .form-control:focus {
            border-color: #2563eb;
            box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
        }
        
        .btn-login {
            background: linear-gradient(135deg, #2563eb, #1d4ed8);
            border: none;
            border-radius: 10px;
            padding: 0.75rem 2rem;
            font-weight: 600;
            font-size: 1.1rem;
            transition: all 0.3s ease;
        }
        
        .btn-login:hover {
            background: linear-gradient(135deg, #1d4ed8, #1e40af);
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
        }
        
        .form-floating {
            margin-bottom: 1.5rem;
        }
        
        .alert {
            border-radius: 10px;
            border: none;
        }
        
        .divider {
            text-align: center;
            margin: 2rem 0;
            position: relative;
        }
        
        .divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: #e5e7eb;
        }
        
        .divider span {
            background: white;
            padding: 0 1rem;
            color: #6b7280;
            font-size: 0.9rem;
        }
        
        .register-link {
            text-align: center;
            margin-top: 1.5rem;
        }
        
        .register-link a {
            color: #2563eb;
            text-decoration: none;
            font-weight: 500;
        }
        
        .register-link a:hover {
            text-decoration: underline;
        }
        
        .brand-logo {
            font-size: 3rem;
            margin-bottom: 1rem;
        }
        
        .remember-me {
            margin: 1.5rem 0;
        }
        
        .form-check-input:checked {
            background-color: #2563eb;
            border-color: #2563eb;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-6 col-lg-5">
                    <div class="card login-card">
                        <div class="login-header">
                            <div class="brand-logo">
                                <i class="bi bi-robot"></i>
                            </div>
                            <h2 class="mb-0">SimpleHire</h2>
                            <p class="mb-0 mt-2 opacity-75">AI简历评分系统</p>
                        </div>
                        
                        <div class="login-body">
                            <!-- Error Messages -->
                            <div class="alert alert-danger" role="alert" th:if="${param.error}">
                                <i class="bi bi-exclamation-triangle me-2"></i>
                                <span th:if="${param.error[0] == 'bad-credentials'}">用户名或密码错误</span>
                                <span th:if="${param.error[0] == 'disabled'}">账户已被禁用</span>
                                <span th:if="${param.error[0] == 'locked'}">账户已被锁定</span>
                                <span th:unless="${param.error[0] == 'bad-credentials' or param.error[0] == 'disabled' or param.error[0] == 'locked'}">登录失败，请重试</span>
                            </div>
                            
                            <!-- Success Messages -->
                            <div class="alert alert-success" role="alert" th:if="${param.logout}">
                                <i class="bi bi-check-circle me-2"></i>
                                您已成功退出登录
                            </div>
                            
                            <div class="alert alert-info" role="alert" th:if="${param.registered}">
                                <i class="bi bi-info-circle me-2"></i>
                                注册成功，请登录
                            </div>
                            
                            <!-- Login Form -->
                            <form th:action="@{/login}" method="post">
                                <div class="form-floating">
                                    <input type="text" 
                                           class="form-control" 
                                           id="username" 
                                           name="username" 
                                           placeholder="用户名或邮箱"
                                           required
                                           th:value="${param.username != null ? param.username[0] : ''}">
                                    <label for="username">
                                        <i class="bi bi-person me-2"></i>用户名或邮箱
                                    </label>
                                </div>
                                
                                <div class="form-floating">
                                    <input type="password" 
                                           class="form-control" 
                                           id="password" 
                                           name="password" 
                                           placeholder="密码"
                                           required>
                                    <label for="password">
                                        <i class="bi bi-lock me-2"></i>密码
                                    </label>
                                </div>
                                
                                <div class="remember-me">
                                    <div class="form-check">
                                        <input class="form-check-input" 
                                               type="checkbox" 
                                               id="remember-me" 
                                               name="remember-me">
                                        <label class="form-check-label" for="remember-me">
                                            记住我
                                        </label>
                                    </div>
                                </div>
                                
                                <div class="d-grid">
                                    <button type="submit" class="btn btn-primary btn-login">
                                        <i class="bi bi-box-arrow-in-right me-2"></i>
                                        登录
                                    </button>
                                </div>
                            </form>
                            
                            <div class="divider">
                                <span>还没有账户？</span>
                            </div>
                            
                            <div class="d-grid">
                                <a href="/register" class="btn btn-outline-primary">
                                    <i class="bi bi-person-plus me-2"></i>
                                    立即注册
                                </a>
                            </div>
                            
                            <div class="register-link">
                                <a href="/">
                                    <i class="bi bi-house me-1"></i>
                                    返回首页
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // Auto-focus on username field
        document.addEventListener('DOMContentLoaded', function() {
            const usernameField = document.getElementById('username');
            if (usernameField && !usernameField.value) {
                usernameField.focus();
            }
        });
        
        // Form validation
        (function() {
            'use strict';
            window.addEventListener('load', function() {
                var forms = document.getElementsByClassName('needs-validation');
                var validation = Array.prototype.filter.call(forms, function(form) {
                    form.addEventListener('submit', function(event) {
                        if (form.checkValidity() === false) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                        form.classList.add('was-validated');
                    }, false);
                });
            }, false);
        })();
    </script>
</body>
</html>